package com.wdd.owntool.ui.lazy

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.wdd.libbase.base.BaseActivity
import com.wdd.owntool.R
import kotlinx.android.synthetic.main.activity_lazy.*

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.owntool.ui
 * @ClassName:      LazyAcrivity
 * @Description:     懒加载验证
 * @Author:         王丹丹
 * @CreateDate:     2019/12/21 11:33
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/21 11:33
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
class LazyActivity : BaseActivity() {
    override fun getLayoutId(): Int {
        return R.layout.activity_lazy
    }

    override fun initView() {
    }

    override fun initData() {
        viewpager.adapter = ViewpagerAdapter(
            supportFragmentManager,
            FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
        )
    }


    inner class ViewpagerAdapter(fm: FragmentManager, behavior: Int) :
        FragmentPagerAdapter(fm, behavior) {

        override fun getItem(position: Int): Fragment {
            return LazyFragment()
        }

        override fun getCount(): Int {
            return 4
        }

    }
}